package com.bj.users.service.impl;

import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.bj.users.dao.IAAdminsDao;
import com.bj.users.pojo.AAdmins;
import com.bj.users.service.IUsersService;

@Service("usersService")
public class UsersServiceImpl implements IUsersService
{
	@Resource
	private IAAdminsDao iAdminsDao;

	@Override
	public AAdmins findOneAdminService(Map<String, Object> condMap)
	{
		return this.iAdminsDao.findOne(condMap);
	}

	@Override
	public List<AAdmins> findListAdminService(Map<String, Object> condMap)
	{
		return this.iAdminsDao.findList(condMap);
	}

	@Override
	public JSONObject insertAdmin(AAdmins admin)
	{
		JSONObject jsonObject = new JSONObject();
		int res = this.iAdminsDao.insert(admin);
		if (res > 0)
		{
			jsonObject.put("code", "0");
			jsonObject.put("info", "插入成功");
		} else
		{
			jsonObject.put("code", "1");
			jsonObject.put("info", "插入失败");
		}
		return jsonObject;
	}

	@Override
	public JSONObject updateAdmin(AAdmins admin)
	{
		JSONObject jsonObject = new JSONObject();
		int res = this.iAdminsDao.update(admin);
		if (res > 0)
		{
			jsonObject.put("code", "0");
			jsonObject.put("info", "更新成功");
		} else
		{
			jsonObject.put("code", "1");
			jsonObject.put("info", "更新失败");
		}
		return jsonObject;
	}

	@Override
	public JSONObject deleteAdmin(AAdmins admin)
	{
		JSONObject jsonObject = new JSONObject();
		int res = this.iAdminsDao.delete(admin);
		if (res > 0)
		{
			jsonObject.put("code", "0");
			jsonObject.put("info", "删除成功");
		} else
		{
			jsonObject.put("code", "1");
			jsonObject.put("info", "删除失败");
		}
		return jsonObject;
	}

}
